/*
int Type <
	string UIName = "Type";
	> = 0;
int SubType <
	string UIName = "SubType";
	> = 0;
*/
// 3ds max effect file
// Simple Lighting Model


//DxMaterial specific 

// light intensity
float4 I_a <
	string UIName = "Ambient";
	> = { 1.0f, 1.0f, 1.0f, 1.0f };    // ambient

texture diffuseTexture : DiffuseMap
< 
    string TextureType = "2D"; 
    string UIName = "Diffuse Texture";
    int Texcoord = 0;
	//int MapChannel = 1;
>;

int ignorethis_diffuseTextureSampler_WrapMode <	//0:Wrap(repeat); 1:Clamp
	string UIName = "Diffuse Texture Wrap Mode";
	> = 0;
	
sampler2D diffuseSampler_Wrap = sampler_state 
{
    texture = (diffuseTexture);
    AddressU  = WRAP;        
    AddressV  = WRAP;
    AddressW  = WRAP;
    MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};

sampler2D diffuseSampler_Clamp = sampler_state 
{
    texture = (diffuseTexture);
    AddressU  = CLAMP;        
    AddressV  = CLAMP;
    AddressW  = CLAMP;
    MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};

// transformations
float4x4 World      : 		WORLD;
float4x4 View       : 		VIEW;
float4x4 Projection : 		PROJECTION;
float4x4 WorldViewProj : 	WORLDVIEWPROJ;
float4x4 WorldView : 		WORLDVIEW;


struct VS_OUTPUT
{
    float4 Pos  : POSITION;
	float2 TexCoord	: TEXCOORD0;
};

VS_OUTPUT VS(
    float3 Pos  : POSITION,
	float2 TexCoord	: TEXCOORD0)
{
    VS_OUTPUT Out = (VS_OUTPUT)0;
	Out.Pos  = mul(float4(Pos,1),WorldViewProj);
	Out.TexCoord = TexCoord;
    return Out;
}



float4 PS(float2 TexCoord  : TEXCOORD0) : COLOR
{
	float4 color;
	if(ignorethis_diffuseTextureSampler_WrapMode == 0)
	{
		color = I_a * tex2D(diffuseSampler_Wrap, TexCoord);
	}
	else
	{
		color = I_a * tex2D(diffuseSampler_Clamp, float2(TexCoord.x, TexCoord.y + 1.0)) + float4(1.0,0.0,0.0,0.0);
	}
    return  color ;
}

technique DefaultTechnique
{
    pass P0
    {
        // shaders
        CullMode = None;
        ShadeMode = Gouraud;
        VertexShader = compile vs_2_0 VS();
        PixelShader  = compile ps_2_0 PS();
    }  
}

